{% extends 'index.html' %}

{% block head-js %}
    <script src="/static/plugin/ckeditor/ckeditor.js"></script>
{% endblock %}

{% block page-left %}
    <div class="publish">
        {% if create_article_obj %}
            <h3>文章《{{ create_article_obj.title }}》已发布，<a href="{% url 'article' create_article_obj.id %}">点我查看</a> </h3>
        {% else %}
            <form method="post" action="{%  url 'publish' %}" enctype="multipart/form-data">{% csrf_token %}
                <input name="title" type="text" class="form-control" placeholder="文章标题" />
                <select name="plate_id" class="form-control">
                    {% for plate in plate_list %}
                        <option value="{{ plate.id }}">{{ plate.plate }}</option>
                    {% endfor %}
                </select>
                <input name="summary" type="text" class="form-control" placeholder="文章简介" />
                <input name="img" type="file" />必选文章标题图片
    {#            CKEditor textarea   编辑器插件 ，先写一个textarea，再用js方法封装   #}
                <textarea id="ck-editor" name="content" class="form-control" rows="3"></textarea>
                <br>
                <button type="submit" class="btn btn-success pull-right" >发帖</button>
            </form>
        {% endif %}
    </div>
{% endblock %}

{% block bottom-js %}
    <script type="text/javascript">
        CKEDITOR.replace('ck-editor');
{#        还也可以自定义配置#}
{#        CKEDITOR.editorConfig = function(config){#}
{#            config.uiColor = '#F7B42C';#}
{#            config.height = 300 ;#}
{#        };#}
    </script>
{% endblock %}